home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CModalDialog.cp
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: xxx put dri here xxx
-
- Other Contact: xxx put other contact here xxx
-
- Technology: xxx put technology here xxx
-
- Writers:
-
- (BWS) Brent Schorsch
-
- Change History (most recent first):
-
- <SP1> 7/1/99 BWS first checked in
- */
-
- //• —————————————————————————————— Includes
-
- #include <ControlDefinitions.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <MacWindows.h>
-
- #include "MemoryHandler.h"
- #include "CModalDialog.h"
-
- //• —————————————————————————————— Private Definitions
- //• —————————————————————————————— Private Types
- //• —————————————————————————————— Private Variables
- //• —————————————————————————————— Private Functions
- //• —————————————————————————————— Public Variables
-
- //• ———————————————————— CModalDialog
-
- CModalDialog::CModalDialog(const short inDialogID)
- {
- dialog = ::GetNewDialog(inDialogID, nil, (WindowPtr) -1L);
-
- numBaseItems = ::CountDITL(dialog);
- }
-
- //• ———————————————————— ~CModalDialog
-
- CModalDialog::~CModalDialog()
- {
- ::DisposeDialogZ(&dialog);
- }
-
- #pragma mark -
-
- //• ———————————————————— CModalDialog::Show
-
- void
- CModalDialog::Show(void)
- {
- ::ShowWindow(dialog);
- }
-
- //• ———————————————————— CModalDialog::Hide
-
- void
- CModalDialog::Hide(void)
- {
- ::HideWindow(dialog);
- }
-
- //• ———————————————————— CModalDialog::MakeCurrentPort
-
- void
- CModalDialog::MakeCurrentPort(void)
- {
- ::SetPort(dialog);
- }
-
- //• ———————————————————— CModalDialog::SetDefaultItem
-
- void
- CModalDialog::SetDefaultItem(const short inWhichItem)
- {
- ::SetDialogDefaultItem(dialog, inWhichItem);
- }
-
- //• ———————————————————— CModalDialog::SetCancelItem
-
- void
- CModalDialog::SetCancelItem(const short inWhichItem)
- {
- ::SetDialogCancelItem(dialog, inWhichItem);
- }
-
- #pragma mark -
-
- //• ———————————————————— CModalDialog::GetItemValue
-
- short
- CModalDialog::GetItemValue(const short inWhichCheckBox)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichCheckBox, &theControl);
-
- return (::GetControlValue(theControl));
- }
-
- //• ———————————————————— CModalDialog::GetEditText
-
- void
- CModalDialog::GetEditText(const short inWhichItem, Str255 outText)
- {
- ControlHandle theControl;
- Size realSize;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
- ::GetControlData(theControl, kControlEditTextPart, kControlEditTextTextTag, 255, (Ptr) &outText[1], &realSize);
-
- outText[0] = realSize;
- }
-
- //• ———————————————————— CModalDialog::GetStaticText
-
- void
- CModalDialog::GetStaticText(const short inWhichItem, Str255 outText)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
- ::GetDialogItemText((Handle) theControl, outText);
- }
-
- //• ———————————————————— CModalDialog::GetItemMenuHandle
-
- MenuHandle
- CModalDialog::GetItemMenuHandle(const short inWhichItem)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
-
- return ((MenuHandle) theControl);
- }
-
- #pragma mark -
-
- //• ———————————————————— CModalDialog::SetItemValue
-
- void
- CModalDialog::GetItemValue(const short inWhichCheckBox, const short inValue)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichCheckBox, &theControl);
- ::SetControlValue(theControl, inValue);
- }
-
- //• ———————————————————— CModalDialog::SetEditText
-
- void
- CModalDialog::SetEditText(const short inWhichItem, Str255 inText)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
- ::SetControlData(theControl, kControlEditTextPart, kControlEditTextTextTag, inText[0], (Ptr) &inText[1]);
- }
-
- //• ———————————————————— CModalDialog::SetStaticText
-
- void
- CModalDialog::SetStaticText(const short inWhichItem, Str255 inText)
- {
- ControlHandle theControl;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
- ::SetDialogItemText((Handle) theControl, inText);
- }
-
- //• ———————————————————— CModalDialog::SelectEditText
-
- void
- CModalDialog::SelectEditText(const short inWhichItem, const short inStart, const short inEnd)
- {
- ControlHandle theControl;
- ControlEditTextSelectionRec selection;
-
- selection.selStart = inStart;
- selection.selEnd = inEnd;
-
- ::GetDialogItemAsControl(dialog, inWhichItem, &theControl);
-
- ::SetControlData(
- theControl,
- kControlEditTextPart,
- kControlEditTextSelectionTag,
- sizeof (ControlEditTextSelectionRec),
- (Ptr) &selection);
- }
-